package com.ndp.fb.enums.admarket;

import lombok.Getter;

/**
 * Created by mikey on 2016/6/28.
 */
@Getter
public enum AdMarketStatus {
    /**
     * CREATE
     */
    CREATE("CREATE", 0),

    /**
     * RUNNING
     */
    RUNNING("RUNNING", 1),

    /**
     * PAUSE
     */
    PAUSE("PAUSE", 2),
	  /**
     * PAUSE
     */
    FAIL("FAIL", 3);

    /**
     * status
     */
    private String status;

    /**
     * code
     */
    private int code;

    /**
     * AdGroupStatus
     *
     * @param status status
     * @param code   code
     */
    private AdMarketStatus(String status, int code) {
        this.status = status;
        this.code = code;
    }

    /**
     * 根据code获取Status
     *
     * @param code code
     * @return Status
     */
    public static AdMarketStatus getStatus(int code) {
        for (AdMarketStatus c : AdMarketStatus.values()) {
            if (c.code == code) {
                return c;
            }
        }
        return null;
    }

    /**
     * 根据status获取Status
     *
     * @param status status
     * @return Status
     */
    public static AdMarketStatus getStatus(String status) {
        for (AdMarketStatus c : AdMarketStatus.values()) {
            if (c.status.equals(status)) {
                return c;
            }
        }
        return null;
    }
}
